<?php include dirname(__FILE__).'/common/header.php'; ?>

<?php include dirname(__FILE__).'/common/menu.php'; ?>

var attr = {};
attr.ctrlName = '<?php echo $ctrlName; ?>';
attr.game_gift = <?php echo $game_gift ?>;
attr.card_type = <?php echo $card_type ?>;
/*
| -------------------------------------------------------------------
|  List Grid
| -------------------------------------------------------------------
*/
list.grid = new ZM.GridPanel({
    url: list.baseUrl + attr.ctrlName+'/getRecordList',
    tbar:[{
        text:'导出过滤核销记录',
        cls:'btn-show',
        hidden:!Ext.permission[attr.ctrlName + '/exportList'.toLowerCase()],
        handler:function() {
            var sortInfo = list.grid.store.getSortState();
            if(sortInfo) {
                list.grid.store.baseParams['sort'] = sortInfo['field'];
                list.grid.store.baseParams['dir'] = sortInfo['direction'];
            }
            location.href = list.baseUrl + attr.ctrlName + '/exportList?'+ Ext.urlEncode(list.grid.store.baseParams);
        }
    }],
    columns:[
        {header:'店面编码',dataIndex:'user_code',filter:{}},
        {header:'店面名称',dataIndex:'user_name',width:150,filter:{}},
        {header:'顾客ID',dataIndex:'customer_id',filter:{}},
        //{header:'openid',dataIndex:'openid',width:150,filter:{}},
        {header:'奖品',dataIndex:'gift_type',sort:true,filter:{xtype:'combofield',options:[['','全部'],['0','无']].concat(attr.game_gift)}
            ,renderer:function(val) {
            return ZM.id2name(val,attr.game_gift);
        }},
        {header:'奖品状态',dataIndex:'gift_status',renderer:function(val) {
            return val == 1 ? '<span style="color:green;">已领取</span>' : '<span style="color:#999;">未领取</span>';
        },filter:{
            xtype:'combofield',
            options:[['','全部'],['1','已领取'],['0','未领取']]
        }},
        {header:'卡券类型',dataIndex:'card_type',width:150,renderer:function(val) {
            return ZM.id2name(val,attr.card_type);
        },filter:{
            xtype:'combofield',
            options:[['','全部']].concat(attr.card_type)
        }},
        {header:'卡券号码',dataIndex:'card_number',width:140,filter:{}},
        {header:'手机号',dataIndex:'record_phone',width:120,filter:{}},
        {header:'姓名',dataIndex:'record_name',filter:{}},
        {header:'车架号',dataIndex:'record_frame_number',width:120,filter:{}},
        {header:'车型',dataIndex:'record_models',filter:{}},
        {header:'核销时间',dataIndex:'record_time_create',width:140,filter:{xtype:'daterangefield'}},
        {header:'操作',renderer:function(v,p,r){
            var str = '';
            if(r.json.gift_type == 4 && r.json.gift_status == 0) {
                str += Ext.rd('标记领取','fireEnable',r,attr.ctrlName+'/markGiftActive');
            }
            return str;
        }}
    ]
});

/*
| -------------------------------------------------------------------
|  List Grid Action
| -------------------------------------------------------------------
*/
list.grid.fireEnable = function(r) {
    var r = r.json;
    Ext.Msg.confirm('确认?','确认要向顾客【'+r.record_name+'】发放实物奖吗?',function(btn) {
        if(btn != 'no') {
            ZM.ajax({
                url: list.baseUrl + attr.ctrlName+'/markGiftActive',
                params:{customer_id:r.customer_id},
                mask:list.grid,
                success:function(res){
                    ZM.bo.msg('success!',res.detail);
                    list.grid.store.reload();
                }
            });
        }
    });
}

<?php include dirname(__FILE__).'/common/layout.php'; ?>
list.grid.store.load();
<?php include dirname(__FILE__).'/common/footer.php'; ?>